﻿namespace Cmn
{
    using System;
    using System.Web;

    public class Session
    {
        public static void Clear()
        {
            HttpContext.Current.Session.Clear();
        }

        public static string Get(string infoName)
        {
            string str = "";
            if (HttpContext.Current.Session[infoName] != null)
            {
                str = Convert.ToString(HttpContext.Current.Session[infoName]);
            }
            return str;
        }

        public static string GetUserID()
        {
            return Get("cmn_UserID");
        }

        public static int GetUserIDNo()
        {
            var s= Get("cmn_UserID");
            return String.IsNullOrEmpty(s) ? -1 : int.Parse(s);
        }

        public static void Set(string infoName, string infoValue)
        {
            HttpContext.Current.Session[infoName] = infoValue;
        }

        public static void SetUserID(string userID)
        {
            Set("cmn_UserID", userID);
        }
    }
}

